using Anvil.Core.Helpers;
using NUnit.Framework;

namespace PhoneBook.Core.Commands
{
    /// <summary>
    /// Exercise formatting processors.
    /// </summary>
    /// 
    [TestFixture]
    public class FormatEntry : BaseTest
    {
        public const string ENTRY_KEY_VALUE_FORMAT = "c5b6bbb1-66d6-49cb-9db6-743af6627828";

        private AppEntry getAppEntry()
        {
            IViewHelper helper = catalog.GetHelperFor(App.ENTRY);
            helper.Criteria[App.ENTRY_KEY] = ENTRY_KEY_VALUE_FORMAT;
            helper.Execute();
            AssertNominal(helper);
            AppEntry entry = new AppEntry(helper.Criteria);
            return entry;
        }

        [Test]
        public void Hired()
        {
            AppEntry entry = getAppEntry();
            string hired = entry.hired;
            Assert.IsNotNull(hired, "Expected row to have a hired date in string format.");
            Assert.IsTrue(hired.Length < "##/##/#### ".Length, hired + ": Expected short date format.");
        }

        [Test]
        public void extension()
        {
            AppEntry entry = getAppEntry();
            string extension = entry.extension;
            Assert.IsNotNull(extension, "Expected each row to have an extension.");
            Assert.IsTrue(extension.Length > "1234567890".Length, extension + ": Expected formatted extension.");
        }
    }
}